package com.duoketech.service.weixin.personal;

import com.duoketech.exception.ValidateException;
import com.duoketech.model.activityorder.ActivityOrder;
import com.duoketech.model.custom.Customization;
import com.duoketech.utils.validator.Validator;
import com.duoketech.utils.validator.rules.string.StringLengthBetween;
import com.duoketech.utils.validator.rules.string.StringMustBeRequired;

import java.util.Date;

public class WxPersonalService {
    public  static WxPersonalService ME = new WxPersonalService();

    public void savePrivateOrder(Customization customization) throws ValidateException {
        Validator validator = new Validator();
        String name = customization.getStr(Customization.NAME);
        String mobile = customization.getStr(Customization.MOBILE);
        String content = customization.getStr(Customization.CONTENT);

        validator.addRule(new StringMustBeRequired(name,"请输入联系人姓名"));
        validator.addRule(new StringMustBeRequired(mobile,"请输入联系人电话"));
        validator.addRule(new StringMustBeRequired(content,"请输入定制的内容信息"));
        validator.addRule(new StringLengthBetween(content,"请输入定制的内容信息200字以内",1,200));
        validator.excute();

        customization.set(Customization.STATUS,Customization.STATUS_NORMAL);
        customization.set(Customization.CREATE_TIME,new Date());
        customization.set(Customization.SOURCE,2);
        customization.set(Customization.TO,1);
        customization.save();
    }

}
